package com.srv.common;

import java.util.HashMap;
import java.util.Map;
import com.srv.util.ObjectField;
import com.srv.util.ObjectFieldDBType;
import com.srv.util.StringUtil;


public class SummaryUserField implements ObjectField{

	private static Map<String, SummaryUserField> map = new HashMap<String, SummaryUserField>();
	
	public static final SummaryUserField PID = new SummaryUserField("PID", ObjectFieldDBType.LONG, false, true);
	
	public static final SummaryUserField USERID = new SummaryUserField("USER_ID", ObjectFieldDBType.STRING, false, true);
	
	public static final SummaryUserField USEREMAIL = new SummaryUserField("USER_EMAIL", ObjectFieldDBType.STRING, false, true);
	
	public static final SummaryUserField PASSWORD = new SummaryUserField("PASSWORD", ObjectFieldDBType.STRING, true, false);
	
	public static final SummaryUserField SINAWEIBOID = new SummaryUserField("SINA_WEIBO_ID", ObjectFieldDBType.STRING, false, true);
	
	public static final SummaryUserField QQWEIBOID = new SummaryUserField("QQ_WEIBO_ID", ObjectFieldDBType.STRING, false, true);
	
	public static final SummaryUserField ISDEL = new SummaryUserField("ISDEL", ObjectFieldDBType.INT, true, false);
	
	public static final SummaryUserField CREATETIME = new SummaryUserField("CREATE_TIME", ObjectFieldDBType.TIMESTAMP, true, false);
	
	public static final SummaryUserField UPDATETIME = new SummaryUserField("UPDATE_TIME", ObjectFieldDBType.TIMESTAMP, true, false);
	
	private String column;
    private ObjectFieldDBType type;
    private boolean modify = false;
    private boolean uniquene = false;
    
    public SummaryUserField(String cn, ObjectFieldDBType type, boolean modify, boolean uniquene) {
    	this.column = cn;
        this.type = type;
        this.modify = modify;
        this.uniquene = uniquene;

        map.put(this.column, this);
    }
    
    public String getColumn() {
        return column;
    }

    public ObjectFieldDBType getType() {
        return type;
    }

    public boolean isModify() {
        return modify;
    }

    public boolean isUniquene() {
        return uniquene;
    }

    public int hashCode() {
        return column.hashCode();
    }
    
    public boolean equals(Object obj) {
        if (obj == null || !(obj instanceof SummaryUserField)) {
            return false;
        }

        return column.equalsIgnoreCase(((SummaryUserField) obj).getColumn());
    }
    
    public static SummaryUserField getByCode(String c) {
        if (StringUtil.isEmpty(c)) {
            return null;
        }

        return map.get(c.toLowerCase());
    }
}
